package cn.haoma.base.socket;


import java.util.Random;

public class Msg {

    public byte cmd;
    public int id;
    public boolean needConfirm;
    public String content;

    public Msg() {
        Random random = new Random();
        int high = random.nextInt(256) << 24;
        id = (int) ((System.currentTimeMillis() & 0xffff) | high);
    }

    @Override
    public int hashCode() {
        return content.hashCode() | (cmd * 37);
    }

    @Override
    public String toString() {
        return MsgProtocol.getCmdName(cmd) + ":" + (content == null ? "" : content);
    }
}
